<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>demo</title>
    <style>
    </style>
</head>

<body>
    <div class="box">
    </div>
    <script>
        let fns = () => {
            const regex = /<img src="(.+?)" alt="(.+?)">/g;
            const str = '<img src="https://example.com/image1.jpg" alt="照片1">' +
                '<img src="https://example.com/image2.jpg" alt="照片2">' +
                '<img src="https://example.com/image3.jpg" alt="照片3">';
                
            const replaced = str.replace(regex, (match, p1, p2) => {
                const newSrc = p1.replace('example.com', 'zengzhi.info').toUpperCase();
                return `<img src="${newSrc}" alt="${p2}">`;
            });
            console.log(replaced);
        }

        console.log(fns());


    </script>
</body>

</html>